package top.yuyufeng.mbuy.enums;

/**
 * 使用枚举表诉常量数据字段
 * @author yuyufeng7
 */
public enum ProductStatusEnum {
    ON_SALE(1, "在售"),
    OFF_SALE(2, "下架"),
    DELETED(3, "删除");

    private int key;

    private String value;

    ProductStatusEnum(int key, String value) {
        this.key = key;
        this.value = value;
    }

    public int getKey() {
        return key;
    }

    public String getValue() {
        return value;
    }

    public static ProductStatusEnum valueOf(int index) {
        for (ProductStatusEnum e : values()) {
            if (e.getKey() == index) {
                return e;
            }
        }
        return null;
    }
}
